import React, { Component } from 'react'
import { Link, Route } from 'react-router-dom'
import Inner from './inner'
import Outer from './outer'
import auth from "./auth";
import { createHashHistory } from 'history'

class List extends Component {

  logout = () => {
    auth.logout()
    alert("退出登录")
    createHashHistory().push('/home')
  }

  render(props) {
    console.log(props, '=====================')
    console.log(this.props.match.path)
    return (
      <div className="List">

        <button onClick={this.logout}>退出登录</button>

        <div>
          <Link to={`${this.props.match.url}/inner`}>国内新闻</Link>
          <Link to={`${this.props.match.url}/outer`}>国外新闻</Link>
        </div>
        <Route path={`${this.props.match.path}/inner`} component={Inner}/>
        <Route path={`${this.props.match.path}/outer`} component={Outer} />
      </div>
    );
  }
}

export default List;
